#!/bin/bash

echo "========================================================================"
echo "🧠 HuBERT模式快速测试"
echo "========================================================================"
echo ""

cd "$(dirname "$0")/code"

eval "$(conda shell.bash hook)"
conda activate whisper-env

export HF_ENDPOINT=https://hf-mirror.com

echo "📥 检查模式可用性..."
python -c "
from mp3_json_enhanced import ENHANCED_MODE_AVAILABLE, HUBERT_MODE_AVAILABLE

print('✓ 标准模式: 可用')
print(f'✓ 增强模式: {\"可用\" if ENHANCED_MODE_AVAILABLE else \"不可用\"}')
print(f'✓ HuBERT模式: {\"可用\" if HUBERT_MODE_AVAILABLE else \"不可用\"}')
print()

if not HUBERT_MODE_AVAILABLE:
    print('❌ HuBERT模式不可用')
    exit(1)

print('🎉 HuBERT模式可用！')
print()
"

if [ $? -ne 0 ]; then
    echo ""
    echo "❌ HuBERT模式检测失败"
    exit 1
fi

echo "🧪 测试HuBERT转录..."
echo ""

python -c "
from hubert_transcription import hubert_transcription_pipeline

result = hubert_transcription_pipeline(
    '../音频仓库/测试mp3（French）.mp3',
    enable_noise_reduction=True
)

print()
print('='*70)
print('✅ HuBERT转录结果')
print('='*70)
print(f'转录长度: {len(result)} 字符')
print(f'转录内容: {result}')
print('='*70)

if len(result) > 100:
    print()
    print('🎉🎉🎉 HuBERT模式工作正常！')
    print()
    print('现在您可以在音频翻译系统中使用：')
    print('  ./运行音频翻译.sh')
    print('  选择模式：3')
else:
    print()
    print('⚠️  转录结果太短，可能有问题')
"

echo ""
echo "========================================================================"
echo "测试完成"
echo "========================================================================"

